<?
   if(!admin_isadmin())die();

//  vwiki
//  graphics
//
//__ METHOD ____________________________________________
    $_action=$_GET['_action'];
    $_lockfile=$_GET['lockfile'];


    if ($_action=="deleteimage")
	printf("<h2>want you delete images $_lockfile ? <a href=\"index.php?appname=$appname&action=admin&lockfile=$_lockfile&_action=confirmdeleteimage\">yes</a></h2>");

    if ($_action=="confirmdeleteimage"){
	admin_writelog("vwiki:delete image");
	unlink("datas/applications/".apptitle($appname)."/images/$_lockfile");
    }

//__ INTERFACE ________________________________________

echo"
<font size=6><b>IMAGES</b></font><br />\n

<table border='2'>

<tr>
    <td style='color: rgb(255, 255, 255); background-color: rgb( 51, 204, 0);'><font size='2'><b>filename</b></font></td>
    <td style='color: rgb(255, 255, 255); background-color: rgb( 51, 204, 0);'><font size='2'><b>preview</b></font></td>
    <td style='color: rgb(255, 255, 255); background-color: rgb( 51, 204, 0);'><font size='2'><b>uploaded</b></font></td>
    <td style='color: rgb(255, 255, 255); background-color: rgb( 51, 204, 0);'><font size='2'><b>in use</b></font></td>
    <td style='color: rgb(255, 255, 255); background-color: rgb( 51, 204, 0);'><font size='2'><b>delete</b></font></td>

</tr>
";
if ($lockdir=@opendir("misc/".sec_title($modname)."/images")) {
	    while(($lockfile=readdir($lockdir))!=false){
		if ($lockfile[0]!="."){
		echo "<tr>";
		echo "<td style='color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);'><font size='2'><b><a href=\"misc/".sec_title($modname)."/images/$lockfile\">$lockfile</a></b></td>\n";
		echo "<td style='color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);'><font size='2'><b><img src=\"misc/".sec_title($modname)."/images/$lockfile\" height='25' /></b></td>\n";
		echo "<td style='color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);'><font size='2'>".date("j F Y g:i a",filemtime("misc/".sec_title($modname)."/images/$lockfile"))."</font></td>\n";

		$is_used="not used";
		if ($hdir=opendir("misc/".sec_title($modname)."/pages")) {
		    while(($hfile=readdir($hdir))!=false){
			if ($hfile[0]!="."){
			    $tmp= file("misc/".sec_title($modname)."/pages/".$hfile);
			    foreach($tmp as $ln){
				if (substr_count($ln,$lockfile)>0){
				    $is_used="used";
				    break;
				}
			    }
			}
			if ($is_used=="used")break;
		    }
		    closedir($hdir);
		}
		echo "<td style='color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);'><font size='2'>$is_used</font></td>\n";
		echo "<td style='color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);'><font size='2'><a href=\"index.php?appname=$appname&action=admin&lockfile=$lockfile&_action=deleteimage\">delete</a></font></td>";
		echo "</tr>\n";

		}

	    }
	    closedir($lockdir);
	}
	echo "</table>\n";
	echo "</font>\n";
	echo "<hr>\n";

//______________________________________________________
?>

